package jumpingnotes.model.entity;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "activity", catalog = "jumping_notes")
public class Activity implements java.io.Serializable
{

	private Integer activityId;
	private ActivityTemplate activityTemplate;
	private Member member;
	private String url;
	private Integer priority;
	private Date createTime;
	private Set<ActivityTemplateParam> activityTemplateParams = new HashSet<ActivityTemplateParam>(0);
	private Set<ActivityMediaItem> activityMediaItems = new HashSet<ActivityMediaItem>(0);

	public Activity()
	{
	}

	public Activity(Member member, Date createTime)
	{
		this.member = member;
		this.createTime = createTime;
	}

	public Activity(ActivityTemplate activityTemplate, Member member, String url, Integer priority, Date createTime,
			Set<ActivityTemplateParam> activityTemplateParams, Set<ActivityMediaItem> activityMediaItems)
	{
		this.activityTemplate = activityTemplate;
		this.member = member;
		this.url = url;
		this.priority = priority;
		this.createTime = createTime;
		this.activityTemplateParams = activityTemplateParams;
		this.activityMediaItems = activityMediaItems;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "activity_id", unique = true, nullable = false)
	public Integer getActivityId()
	{
		return this.activityId;
	}

	public void setActivityId(Integer activityId)
	{
		this.activityId = activityId;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "title_template_id")
	public ActivityTemplate getActivityTemplate()
	{
		return this.activityTemplate;
	}

	public void setActivityTemplate(ActivityTemplate activityTemplate)
	{
		this.activityTemplate = activityTemplate;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "member_id", nullable = false)
	public Member getMember()
	{
		return this.member;
	}

	public void setMember(Member member)
	{
		this.member = member;
	}

	@Column(name = "url", length = 100)
	public String getUrl()
	{
		return this.url;
	}

	public void setUrl(String url)
	{
		this.url = url;
	}

	@Column(name = "priority")
	public Integer getPriority()
	{
		return this.priority;
	}

	public void setPriority(Integer priority)
	{
		this.priority = priority;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "create_time", nullable = false, length = 19)
	public Date getCreateTime()
	{
		return this.createTime;
	}

	public void setCreateTime(Date createTime)
	{
		this.createTime = createTime;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "activity")
	public Set<ActivityTemplateParam> getActivityTemplateParams()
	{
		return this.activityTemplateParams;
	}

	public void setActivityTemplateParams(Set<ActivityTemplateParam> activityTemplateParams)
	{
		this.activityTemplateParams = activityTemplateParams;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "activity")
	public Set<ActivityMediaItem> getActivityMediaItems()
	{
		return this.activityMediaItems;
	}

	public void setActivityMediaItems(Set<ActivityMediaItem> activityMediaItems)
	{
		this.activityMediaItems = activityMediaItems;
	}

}
